import { Entity, Column, PrimaryGeneratedColumn, OneToOne, JoinColumn } from 'typeorm';
import { NV_Users } from './user.entity';

@Entity()
export class UserDetails {
  // 主键自增列
  @PrimaryGeneratedColumn()
  id: number;

  // 与 NV_Users 实体中的 user_id 字段关联
  @Column({ type: 'varchar', length: 20, nullable: true })
  user_id: string;

  // 一对一关联 NV_Users 实体
  @OneToOne(() => NV_Users, (user) => user.details)
  @JoinColumn()
  user: NV_Users;

  @Column({ type: 'varchar', length: 14, nullable: true })
  firstName: string | null;

  @Column({ type: 'varchar', length: 14, nullable: true })
  lastName: string | null;

  @Column({ type: 'varchar', length: 255, nullable: true })
  image_url: string | null;
}